// $ID$
// vim:ft=javascript

ARG_ENABLE("mongo", "MongoDB support", "no");
ARG_ENABLE("mongo-streams", "Mongo: Build with PHP streams wrapper support", "yes");
ARG_WITH("mongo-sasl", "Mongo: Build against Cyrus-SASL", "yes");
ADD_EXTENSION_DEP("mongo", "openssl", false);

if (PHP_MONGO != "no") {
  EXTENSION('mongo', 'php_mongo.c mongo.c mongoclient.c bson.c collection.c command_cursor.c cursor.c cursor_shared.c db.c io_stream.c log_stream.c');
  ADD_SOURCES(configure_module_dirname + "/contrib", "php-json.c php-ssl.c crypto.c", "mongo");
  ADD_SOURCES(configure_module_dirname + "/exceptions", "exception.c connection_exception.c cursor_exception.c cursor_timeout_exception.c execution_timeout_exception.c gridfs_exception.c duplicate_key_exception.c result_exception.c write_concern_exception.c protocol_exception.c ", "mongo");
  ADD_SOURCES(configure_module_dirname + "/gridfs", "gridfs.c gridfs_cursor.c gridfs_file.c gridfs_stream.c", "mongo");
  ADD_SOURCES(configure_module_dirname + "/types", "bin_data.c code.c date.c db_ref.c id.c int32.c int64.c regex.c timestamp.c", "mongo");
  ADD_SOURCES(configure_module_dirname + "/util", "log.c pool.c", "mongo");
  ADD_SOURCES(configure_module_dirname + "/mcon", "bson_helpers.c collection.c connections.c manager.c mini_bson.c parse.c read_preference.c str.c utils.c", "mongo");
  ADD_SOURCES(configure_module_dirname + "/mcon/contrib", "md5.c strndup.c", "mongo");
  ADD_SOURCES(configure_module_dirname + "/api", "batch.c write.c wire_version.c", "mongo");
  ADD_SOURCES(configure_module_dirname + "/batch", "delete.c insert.c update.c write.c", "mongo");

  AC_DEFINE('HAVE_MONGO', 1);

  if (PHP_MONGO_SASL != "no") {
    if (CHECK_LIB("libsasl.lib", "mongo", PHP_MONGO)) {
      ADD_FLAG("CFLAGS_MONGO", " /D HAVE_MONGO_SASL=1");
    } else {
      WARNING("mongo libsasl support not enabled, libs not found");
    }
  }

  if (CHECK_LIB("ssleay32.lib", "mongo", PHP_MONGO) && CHECK_LIB("libeay32.lib", "mongo", PHP_MONGO)) {
    ADD_FLAG("CFLAGS_MONGO", " /D HAVE_MONGO_OPENSSL=1");
  }
}

